package xps.and.uudaijia.userclient.view.fragment;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.zhy.autolayout.AutoLinearLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import jp.wasabeef.glide.transformations.CropCircleTransformation;
import xps.and.uudaijia.userclient.R;
import xps.and.uudaijia.userclient.view.base.BaseFragment;

/**
 * Created by Administrator on 2017/6/27.
 */
@SuppressLint("NewApi")
public class StateFragment extends BaseFragment {
    Unbinder unbinder;
    public static int ObtainStart = 0;
    public static int ObtainEnd = 1;
    @BindView(R.id.name_TextView)
    public TextView nameTextView;
    @BindView(R.id.ok_TextView)
    public TextView okTextView;
    @BindView(R.id.end_TextView)
    public TextView endTextView;
    @BindView(R.id.yingcang)
    public AutoLinearLayout yingcang;
    @BindView(R.id.TX_ImageView)
    public ImageView TXImageView;
    @BindView(R.id.dianhua_img)
    ImageView dianhuaImg;
    private Context mContext;
    MapViewFragment mapViewFragment;
    public static final double LATITUDE_B = 39.1425870000;  //终点纬度
    public static final double LONGTITUDE_B = 117.1197700000;
    String userPhone, remark, endAddress, endLat, endLng, beginAddress, beginLng, beginLat, OrderId, driverName, driverHeadImg;

    @Override
    protected int getRes() {
        return R.layout.fragment_state;
    }

    @Override
    protected void init(View view) {
        mapViewFragment = new MapViewFragment();
        mContext = getContext();
        unbinder = ButterKnife.bind(this, view);
        Bundle bundle = getArguments();
        userPhone = bundle.getString("userPhone");
        remark = bundle.getString("remark");
        endAddress = bundle.getString("endAddress");
        endLat = bundle.getString("endLat");
        endLng = bundle.getString("endLng");
        beginAddress = bundle.getString("beginAddress");
        beginLng = bundle.getString("beginLng");
        beginLat = bundle.getString("beginLat");
        OrderId = bundle.getString("OrderId");
        driverName = bundle.getString("driverName");
        driverHeadImg = bundle.getString("driverHeadImg");
        okTextView.setText(beginAddress);
        endTextView.setText(endAddress);
        nameTextView.setText(driverName + "师傅");

        Glide.with(getActivity()).load(driverHeadImg)
                .placeholder(R.mipmap.logo)
                .bitmapTransform(new CropCircleTransformation(getActivity()))
                .into(TXImageView);
    }

    @Override
    protected void setData(View view) {

    }

    @Override
    public void onClick(View v) {

    }

    @OnClick(R.id.dianhua_img)
    public void onViewClicked() {
        Intent phoneIntent = new Intent("android.intent.action.CALL",
                Uri.parse("tel:" + userPhone));
        //启动
        startActivity(phoneIntent);
    }

    private Handler handler = new Handler() {
        public void handleMessage(Message message) {
            Bitmap bitmap = (Bitmap) message.obj;
            TXImageView.setImageBitmap(bitmap);

        }
    };
}
